//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "client\fn_clientAIActions.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_act_id","_action_title","_arguments","_condition"];
waituntil { !isnull player && {alive player} };
sleep 3;
// We use global object vars because this action is generic and applies to all missions. We won't remove it.
_act_id = PGETVAR(QGVAR(TELEPORT_AI_ACTION),-1);
TRACE_2("Check Action",QGVAR(TELEPORT_AI_ACTION),_act_id);
// if (isnil "_act_id" || _act_id < 0) then {
	_action_title = ["STR_TMF_TELEPORT_AI"] call FFUNC(translate);
	_arguments = [];
	_arguments set [TMF_EXECUTE_ACTION_PARAM_ACTID, -1];
	_arguments set [TMF_EXECUTE_ACTION_PARAM_FUNC, "TeleportAI"];
	_condition = format["((alive player) && {(player == leader player)} && {vehicle player == player} && {[player] call tmf_fnc_hasTMFAI})"];
	_act_id = player addAction [_action_title, QPATH(addAction.sqf),_arguments,-10,False,True,"",_condition];
	PSETVAR(QGVAR(TELEPORT_AI_ACTION),_act_id);
	TRACE_2("Added Action",_action_title,_act_id);
// };

// We use global object vars because this action is generic and applies to all missions. We won't remove it.
_act_id = PGETVAR(QGVAR(RELEASE_AI_ACTION),-1);
TRACE_2("Check Action",QGVAR(RELEASE_AI_ACTION),_act_id);
// if (isnil "_act_id" || _act_id < 0) then {
	_action_title = ["STR_TMF_RELEASE_AI"] call FFUNC(translate);
	_arguments = [];
	_arguments set [TMF_EXECUTE_ACTION_PARAM_ACTID, -1];
	_arguments set [TMF_EXECUTE_ACTION_PARAM_FUNC, "ReleaseAI"];
	_condition = format["((alive player) && {(player == leader player)} && {vehicle player == player} && {[player] call tmf_fnc_hasTMFAI})"];
	_act_id = player addAction [_action_title, QPATH(addAction.sqf),_arguments,-10,False,True,"",_condition];
	PSETVAR(QGVAR(RELEASE_AI_ACTION),_act_id);
	TRACE_2("Added Action",_action_title,_act_id);
// };

TRACE("End");
TMFPROFILERSTOP;